barGraph <- function(x, rel=FALSE, cum=FALSE, poly=FALSE, ...){
   if(cum){  
      if(rel){
		  freq = cumsum(table(x))/length(x)
		  .x = barplot(freq, ylab="Frecuencia relativa acumulada", ...)[,1]
	  }
      else{
		  freq = cumsum(table(x))
		  .x = barplot(freq, ylab="Frecuencia absoluta acumulada", ...)[,1] 
	  }
		 
	  if(poly){
		  n=length(freq)
		  .x = c(rep(.x, rep(2,n)), .x[n]+(.x[n]-.x[n-1])/2)
		  .y = c(0,rep(freq, rep(2, n)))
		  lines(.x,.y)
	 }
   }
   else{
      if(rel){
		 freq = table(x)/length(x)
		 .x = barplot(freq, ylab="Frecuencia relativa", ...)[,1]
	  }   
      else{
		  freq = table(x)
		  .x = barplot(freq, ylab="Frecuencia absoluta", ...)[,1]
	  }
        
	  if(poly){
		 lines(.x,freq)
	 }
   }
}

